import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent, STData } from '@delon/abc';
import { SFSchema } from '@delon/form';
import { DictService } from '@shared';

@Component({
  selector: 'app-isps-announcement',
  templateUrl: './announcement.component.html',
})
export class IspsAnnouncementComponent implements OnInit {
  url = `system/sysAnnouncementSend/getMyAnnouncementSend`;
  searchSchema: SFSchema = {
    properties: {
      titile: {
        type: 'string',
        title: '标题'
      },
      sender: {
        type: 'string',
        title: '发布人'
      }
    }
  };
  @ViewChild('st',{static:true}) st: STComponent;
  columns: STColumn[] = [
    { title: '标题', index: 'titile' },
    { title: '消息类型', index: 'msgCategory_dictText' },
    { title: '发布人', index: 'sender' },
    { title: '发布时间', index: 'sendTime' },
    { title: '优先级', index: 'priority_dictText' },
    { title: '阅读状态', index: 'readFlag',format:(item: STData)=> this.dictService.getDictValue('read_flag',item.readFlag)},

    {
      title: '',
      buttons: [
         { text: '查看', click: (item: any) => `/form/${item.id}` },
        // { text: '编辑', type: 'static', component: FormEditComponent, click: 'reload' },
      ]
    }
  ];

  constructor(private http: _HttpClient, private modal: ModalHelper,private dictService:DictService) { }

  ngOnInit() { }

  readAll(){
    console.log("666")
    this.http.put(`system/sysAnnouncementSend/readAll`).subscribe();
  }
  add() {
    // this.modal
    //   .createStatic(FormEditComponent, { i: { id: 0 } })
    //   .subscribe(() => this.st.reload());
  }

}
